package com.ztf.client;

import com.ztf.bean.DataTransfer;
import com.ztf.clientThread.AcceptThread;

import java.io.*;
import java.net.Socket;

public class Client {
    private static ObjectOutputStream oos;

    static {
        try {
            Socket so = new Socket("127.0.0.1",8080);
            OutputStream os = so.getOutputStream();
            oos = new ObjectOutputStream(os);
            InputStream is = so.getInputStream();
            ObjectInputStream ois = new ObjectInputStream(is);
            new AcceptThread(ois).start();


        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void send(Object dt){
        try {
            oos.writeObject(dt);
        } catch (IOException e) {
            System.out.println("发送异常");
            e.printStackTrace();
        }
    }
}
